package com.yhp.exception;

import com.yhp.utils.JSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import springfox.documentation.spring.web.json.Json;

import javax.validation.constraints.Max;

//自定义异常处理类
@RestControllerAdvice
public class CustomException {

    //上传文件超过500k，捕获这个异常
    @ExceptionHandler(MaxUploadSizeExceededException.class)
   public JSONResult faceUploadException(MaxUploadSizeExceededException e){
        return JSONResult.errorMsg("文件大小不能超过500k,请压缩大小后重新上传");
    }
}
